Skip to content

Add Phase 4 edge case test coverage for rules packages - #156

Merged
jeduden merged 3 commits into
mainfrom
claude/plan-85-other-phases-4-3fyx8
Apr 21, 2026
Merged

Add Phase 4 edge case test coverage for rules packages#156
jeduden merged 3 commits into
mainfrom
claude/plan-85-other-phases-4-3fyx8

Conversation

@jeduden

@jeduden jeduden commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds comprehensive test coverage for edge cases and error paths across four rule packages (concisenessscoring/classifier, crossfilereferenceintegrity, requiredstructure, and catalog), targeting Phase 4 of the coverage improvement plan. These tests cover validation logic, error handling, and boundary conditions that were previously untested.

Key Changes

concisenessscoring/classifier

  • Added TestValidateArtifact_* tests covering field validation:
    • Empty model_id and version fields
    • Invalid threshold values (0, 1, -0.1, 1.5)
    • Empty weights map
  • Added TestCompileLexicon_* tests for per-list validation:
    • Insufficient filler words, modal words, and vague words

crossfilereferenceintegrity

  • Added TestDefaultSettings to verify default rule configuration
  • Added TestCheck_InvalidIncludeGlobReturnsConfigDiag for invalid glob pattern handling
  • Added TestParseTarget_* tests covering edge cases:
    • Anchor-only targets (#section)
    • Empty strings, protocol-relative URLs, absolute URLs
    • Paths with anchors and percent-encoded characters
  • Added TestToStringSlice_* tests for type conversion edge cases
  • Added TestCheck_AnchorOnlyLinkMissingHeading for anchor validation

requiredstructure

  • Added TestCueExprForValue_* tests for CUE expression generation:
    • Slice arrays, maps, empty strings, and unsupported types
  • Added TestExtractYAML_* tests for YAML front matter extraction:
    • Normal case, closing without newline, missing closing delimiter
  • Added TestHeadingText_WithCodeSpan for code span handling in headings
  • Added TestAdvanceToMatch_* tests for heading matching logic:
    • No match scenarios and empty lists
  • Added TestExtractPIFileParam_MultiLine for multi-line processing instruction parsing

catalog

  • Added TestRule_Category to verify rule categorization
  • Added TestResolveGitignore_* tests for gitignore resolution:
    • Disabled by parameter, no matcher available, with matcher and source dir
  • Added TestScanIncludesForTarget_* tests for include scanning fallback paths:
    • Max depth exceeded, file read errors, no includes, direct matches, cycle detection

Documentation

  • Updated plan/85_coverage-to-95-percent.md to mark Phase 4 tasks as complete
  • Added coverage.out to .gitignore for test coverage artifacts

Notable Implementation Details

  • Tests use table-driven patterns where appropriate (e.g., TestValidateArtifact_InvalidThreshold)
  • Error message validation ensures proper error reporting via strings.Contains
  • Temporary directories and mock filesystems (fstest.MapFS) used for file I/O testing
  • Tests verify both success and failure paths for comprehensive coverage

https://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat

claude added 2 commits April 21, 2026 06:32
Cover low-coverage paths in requiredstructure (cueExprForValue
with []any/map inputs, extractYAML unclosed front matter,
writeNodeText CodeSpan branch, advanceToMatch no-match path,
extractPIFileParam multi-line PI), crossfilereferenceintegrity
(DefaultSettings, configDiag via invalid glob, parseTarget
anchor-only/encoded/empty/protocol-relative, toStringSlice
mixed-type []any), concisenessscoring/classifier (validateArtifact
per-field errors, compileLexicon per-list insufficiency), and
catalog (Category, scanIncludesForTarget depth/read/match/cycle
fallbacks, resolveGitignore disabled/no-matcher/source-dir paths).

Coverage improvements: catalog 92.8→94.1%, crossfilereferenceintegrity
85.8→88.1%, requiredstructure 87.9→90.9%, classifier 90.2→93.4%.

https://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat
Copilot AI review requested due to automatic review settings April 21, 2026 06:40
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.69%. Comparing base (24656d9) to head (c703ca6).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   87.06%   87.69%   +0.62%     
==========================================
  Files          97       97              
  Lines       10346    10346              
==========================================
+ Hits         9008     9073      +65     
+ Misses        856      805      -51     
+ Partials      482      468      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands unit test coverage for Phase 4 edge cases across multiple mdsmith rule packages, focusing on previously untested validation/error paths and boundary conditions to support the repo’s coverage-improvement plan.

Changes:

  • Added new edge-case/unit tests for requiredstructure, crossfilereferenceintegrity, concisenessscoring/classifier, and catalog.
  • Updated the coverage plan to mark Phase 4 tasks (and local “run tests/lint” checklist) as completed.
  • Ignored coverage.out to prevent coverage artifacts from being accidentally committed.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plan/85_coverage-to-95-percent.md Marks Phase 4 coverage tasks as completed and records test/lint runs.
internal/rules/requiredstructure/rule_test.go Adds tests for CUE expr generation, YAML extraction edge cases, heading text CodeSpan path, heading matching no-match paths, and multi-line PI parsing.
internal/rules/crossfilereferenceintegrity/rule_test.go Adds tests for defaults, invalid glob → config diagnostic, parseTarget edge cases, type conversion failures, and anchor-only missing heading behavior.
internal/rules/concisenessscoring/classifier/model_test.go Adds tests for artifact validation failures and per-list lexicon minimum-size validation.
internal/rules/catalog/rule_test.go Adds tests for rule category, gitignore resolution variants, and include-scan fallback paths (depth/read errors/no includes/direct match/cycle skip).
.gitignore Adds coverage.out ignore entry for coverage artifacts.

Comment thread plan/85_coverage-to-95-percent.md
Mark "All tests pass" and "golangci-lint reports no issues" as
completed in the Acceptance Criteria section, consistent with the
Phase 4 run-checklist already marked done.

https://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Apr 21, 2026
@jeduden

jeduden commented Apr 21, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Apr 21, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-156-1776802252. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 21, 2026
@jeduden

jeduden commented Apr 21, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit 2306b95. CI run that validated the merge.

Next: Done — nothing more to do here.

@jeduden
jeduden merged commit 2306b95 into main Apr 21, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants